package cn.ghx.xboot.douyin;

import cn.ghx.xboot.client.Client;
import cn.ghx.xboot.common.Result;
import cn.ghx.xboot.douyin.vo.Code2SessionVo;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/douyin")
public class DouyinController {

    public static final String POST_CODE_SESSION = "/code2session";


    private final DouyinService service;

    public DouyinController(DouyinService service) {
        this.service = service;
    }


    @PostMapping(POST_CODE_SESSION)
    public Result<Client> getCodeSession(@RequestBody Code2SessionVo vo) throws Exception {
        return Result.success(service.code2SessionClient(vo.getCode(), vo.getAnonymousCode()));
    }
}
